package com.hontech.kaltaapp.device.event

import com.hontech.kaltaapp.utils.isBitSet

class TempStatus (value: Int) {

    val value: Float
    val internalValue: Float
    val scv: Boolean
    val scg: Boolean
    val oc: Boolean

    init {
        var temp = (value shr 18) and 0x3FFF
        if ((temp and 0x2000) != 0x00) {
            this.value = -(0x4000 - temp) * 0.25f
        } else {
            this.value = temp * 0.25f
        }
        temp = (value shr 4) and 0xFFF
        if ((temp and 0x800) != 0) {
            this.internalValue = -(0x1000 - temp) * 0.0625f
        } else {
            this.internalValue = temp * 0.0625f
        }
        this.scv = value.isBitSet(2)
        this.scg = value.isBitSet(1)
        this.oc = value.isBitSet(0)
    }
}

